package pers.cj.pdos.controller.entity;


/**
 * 响应json体,其中带数据
 */
public class ResponseData extends BaseEntity {
    private Object data;

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static ResponseData success(Object data,String msg){
        ResponseData entity = new ResponseData();
        entity.setCode(1);
        entity.setMsg(msg);
        entity.setData(data);
        return entity;
    }

    public static ResponseData success(Object data){
        ResponseData entity = new ResponseData();
        entity.setCode(1);
        entity.setMsg("处理成功");
        entity.setData(data);
        return entity;
    }

    public static ResponseData fail(String msg){
        ResponseData entity = new ResponseData();
        entity.setCode(2);
        entity.setMsg(msg);
        entity.setData(null);
        return entity;
    }

    public static ResponseData fail(String msg, Object data){
        ResponseData entity = new ResponseData();
        entity.setCode(2);
        entity.setMsg(msg);
        entity.setData(data);
        return entity;
    }
}
